import os,sys,random,string
from app import app,request,basedir,json
baseUrl = 'http://127.0.0.1:5000'
def usual_save_img(img_files):
    ran_str = ''.join(random.sample(string.ascii_letters + string.digits, 16))
    path = basedir+"/static/img/brands/"
    imgName = ran_str+img_files.filename
    file_path = path+imgName
    img_files.save(file_path)
    img_url = '/static/img/brands/'+imgName
    return img_url

def res_json(code,msg,data):
    resData = {
        'code':code,
        'msg':msg,
        'data':data
    }
    return json.dumps(resData,ensure_ascii = False)

def file_len(files_s):
    size = '0'
    try:
        size = len(files_s.read())
    except:
        print('error')
    return str(size)
